/* 1001:Exponentiation */
/*
描述
Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many computer systems.

This problem requires that you write a program to compute the exact value of Rnwhere R is a real number ( 0.0 < R < 99.999 ) and n is an integer such that 0 < n <= 25.

输入
The input will consist of a set of pairs of values for R and n. The R value will occupy columns 1 through 6, and the n value will be in columns 8 and 9.
输出
The output will consist of one line for each line of input giving the exact value of R^n. Leading zeros should be suppressed in the output. Insignificant trailing zeros must not be printed. Don't print the decimal point if the result is an integer.
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <string.h>

using namespace std;

const int MAX_LEN = 1000;
int ia[MAX_LEN];

string subF(string str1, string str2)
{
     int i,j;
     string result;
     memset(ia,0,sizeof(ia));

     reverse(str1.begin(), str1.end());
     reverse(str2.begin(), str2.end());

     int point1, point2,point;
     point1 = str1.find('.');
     point2 = str2.find('.');
     if(point1 != string::npos)
          str1.erase(str1.begin()+point1);
     else
          point1 = 0;
     if(point2 != string::npos)
          str2.erase(str2.begin()+point2);
     else
          point2 = 0;
     point1 > point2 ? point = point1 : point = point2;

     int len1 = str1.size();
     int len2 = str2.size();

     for(i = 0; i < len1; i++)
          for(j = 0; j < len2; j++)
               ia[i+j] += (str1[i]-'0')*(str2[j]-'0');

     int len;
     for(i = 0; i < len1+len2; i++)
     {
          if(ia[i] >= 10)
          {
               ia[i+1] += (ia[i]/10);
               ia[i] %= 10;
          }
     }
     if(ia[len1+len2-1] > 0)
          len = len1+len2;
     else
          len = len1+len2-1;

     for(i = len-1; i >= 0; i--)
          result += char(ia[i]+'0');
     if(point > 0)
     {
          result.insert(result.end()-point1-point2,'.');
          for(i = result.size()-1; i >= 0; i--)
          {
               if(result[i] == '0')
                    result.erase(result.begin()+i);
               else if(result[i] == '.')
               {
                   result.erase(result.begin()+i);
                   break;
               }
               else
                    break;
          }
          while( (*result.begin()) == '0' )
              result.erase(result.begin());
     }
     return result;
}

int main()
{

     string str1;
     int n;
     while(cin >> str1 >> n)
     {
         string str2("1");
         while(n--)
         {
           str2 = subF(str1, str2);
         }
          cout << str2 << endl;
     }
     system("pause");
     return 0;
}


// Compile Error 但是我这里运行只有有两个警告，仍能正确运算
/*
编译错误信息
/home/runner/temp/8064941.673113/Main.cc: In function ‘std::__cxx11::string subF(std::__cxx11::string, std::__cxx11::string)’:
/home/runner/temp/8064941.673113/Main.cc:15:28: error: ‘memset’ was not declared in this scope
      memset(ia,0,sizeof(ia));
*/
